package com.eshin.autotest.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author Eshin
 * @title: HelloService
 * @projectName pay
 * @date 2019/5/2710:58
 */

@Component
@Lazy
public class HelloService {

    @Autowired
    TestService testService;
//    TestService testService;
//    //相互引用的双方，如果均使用构造方法注入，则会出现死循环，双方都不能构造出实例，双方都在等对方的实例
//    public HelloService(TestService testService) {
//        this.testService = testService;
//    }

    @PostConstruct
    public void init(){
        System.out.println("hello service init...");
    }
//    @CustomAsync
    public void doService(){
        testService.doService();
        System.out.println(Thread.currentThread().getName());
        System.out.println("hello service");
    }

    public void setTestService(TestService testService) {
        this.testService = testService;
    }
}
